#include "TeacherGroupsTable.h"
#include "Ext\FilterQuery.h"

namespace TCServer
{
    namespace Store
    {
        QList<QVariantMap> TeacherGroupsTable::query(quint64 idBegin, quint64 idEnd)
        {
            FilterQuery q;
            q.prepare(R"(
			SELECT `p2pteachergroups`.`id`,
				`p2pteachergroups`.`subject`,
				`p2pteachergroups`.`image`
			FROM `tc`.`p2pteachergroups`
			WHERE `id` BETWEEN ? AND ?
			ORDER BY `id` ASC;

			)");
            q.addBindValue(idBegin);
            q.addBindValue(idEnd);


            QList<QVariantMap> res;
            q.exec();
            while (q.next())
            {
                res.append(
                {
                    { "id", q.nextValue().toULongLong() },
                    { "subject", q.nextValue().toUInt() },
                    { "image", q.nextValue().toString() },
                });
            }
            return res;
        }
    }
}